using UnityEngine;

public class ShowPieceUI : MonoBehaviour
{
	public UIEventListener closebtn;

	public UILabel namelabel;

	public UILabel infolabel;

	public UISprite pieceflag;

	public Animator animator;
	//public Animation scaleanima;

	private GameObject objui;

	private bool isshow;

	public UISprite piecekuang;

	private void Start()
	{
		closebtn.onClick = OnClickcloseBtn;
	}

	public void enable(PieceData pd)
	{
		if (objui == null)
		{
			objui = base.gameObject;
		}
		UnityVersionUtil.SetActiveRecursive(objui, state: true);
		isshow = true;
		/* scaleanima["PopWinAnimation"].time = 0f;
		scaleanima["PopWinAnimation"].speed = 1f;
		scaleanima.Play(); */
		animator.SetTrigger("popWin1");
		pieceflag.spriteName = "GY_SP_" + pd.id;
		if (pd.id % 2 == 0)
		{
			piecekuang.spriteName = "JS_jiangLi_Z";
		}
		else
		{
			piecekuang.spriteName = "JS_jiangLi_S";
		}
		switch (pd.type)
		{
			case 0:
				namelabel.text = "战斗机部件";
				break;
			case 1:
				namelabel.text = "护甲";
				break;
			case 2:
				namelabel.text = "机枪部件";
				break;
			case 3:
				namelabel.text = "超远程导弹部件";
				break;
			case 4:
				namelabel.text = "多目标导弹部件";
				break;
			case 5:
				namelabel.text = "导弹诱饵部件";
				break;
		}
		infolabel.text = "一件部件用于解锁 \"" + pd.description + "\"";
	}

	public void OnClickcloseBtn(GameObject btn)
	{
		if (isshow)
		{
			isshow = false;
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
			/* scaleanima["PopWinAnimation"].time = scaleanima.clip.length;
			scaleanima["PopWinAnimation"].speed = -1f;
			scaleanima.Play(); */
			animator.SetTrigger("popWin2");
			Invoke("disable", animator.runtimeAnimatorController.animationClips[0].length);
		}
	}

	public void disable()
	{
		if (MidLoading.loadlevel == 2)
		{
			gamebackctl.instance.BackGameUIstate();
		}
		else
		{
			MenuBackController.instance.BackMenuUIstate();
		}
		UnityVersionUtil.SetActiveRecursive(objui, state: false);
	}
}
